interface IValueWithLength {
    length: number;
}

const getArray = <T extends IValueWithLength>(arg: T, times: number): T[] => {
    return new Array(times).fill(arg);
};

getArray("123", 3);
getArray({
    length: 3,
}, 3);

const getProps = <T, K extends keyof T>(object: T, propName: K): any => {
    return object[propName];
};
